<!-- annotation error -->
<template>
  <div>
    <button @click="submit">
      submit
    </button>
    <div>
      value={{ value }}
    </div>
    <div>
      errMessage={{ errMessage }}
    </div>
  </div>
</template>

<script lang="ts">
import { Vue, Component } from "kaygnas-vue-property-decorator";
import { ErrorReset, ErrorPost, ErrorIntercept } from "@/annotations/error-intercept";
import MessageError from "@/errors/MessageError";

@Component({
  name: "Demo2",
})
export default class Demo2 extends Vue {

  @ErrorReset("submit", () => [])
  public value: any[] = [1,2,3];

  public errMessage: string = "";
  @ErrorPost("submit")
  public async onSublitError(error: Error) {
    this.errMessage = error.message;
  }

  @ErrorIntercept("submit")
  public async submit() {
    throw new MessageError("执行失败");
  }
}
</script>

